package com.daz.common.component.entity;

import java.io.Serializable;

/**
 * 分页类
 *
 * @author dingazheng
 */
public class Page implements Serializable {

    private static final long serialVersionUID = -6113928039738379015L;
    private int pageNum;
    private int pageSize;
    private static final int DEFAULT_PAGE_NUM = 1;//默认当前页
    private static final int DEFAULT_PAGE_SIZE = 20;//默认分页大小

    public Page() {
        this(DEFAULT_PAGE_NUM, DEFAULT_PAGE_SIZE);
    }

    public Page(int pageNum, int pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public int getPageNum() {
        return pageNum <= 0 ? DEFAULT_PAGE_NUM : pageNum;
    }


    public void setPageNum(int pageNum) {
        this.pageNum = (pageNum <= 0) ? DEFAULT_PAGE_NUM : pageNum;
    }

    public int getPageSize() {
        return pageSize <= 0 ? DEFAULT_PAGE_SIZE : pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = (pageSize <= 0) ? DEFAULT_PAGE_SIZE : pageSize;
    }

    @Override
    public String toString() {
        return "Page [pageNum=" + pageNum + ", pageSize=" + pageSize + "]";
    }
}
